package com.cqupt.controller;

import java.util.List;
import java.util.Map;

import com.cqupt.pojo.Loginlogs;
import com.cqupt.service.LoginlogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@Controller
@RequestMapping("loginlos")
@ResponseBody
public class LoginlogsController {
    /**
     * 注入依赖
     */
    @Autowired
    private LoginlogsService loginlogsService;

    /**
     * 查询日志
     * @return
     */
    @RequestMapping(value="/queryAllLogs",method=RequestMethod.POST)
    @ResponseBody
    public List<Loginlogs> queryAllSysLogData(){
        return loginlogsService.queryAllLogs();
    }

    /**
     * 增加日志
     * @return
     */
    @RequestMapping(value="/addLoginlogs",method=RequestMethod.POST)
    @ResponseBody
    public int addLoginlogs(){
        Loginlogs loginlogs = new Loginlogs(null,"信息","登录","测试老张","127.0.0.1","成功","测试老张测试");
        return loginlogsService.addLoginlogs(loginlogs);
    }

    /**
     * 查询日志(过滤)
     * @param params
     * @return
     */
    @RequestMapping(value="/queryLogsByFilter", method = RequestMethod.POST)
    public List<Loginlogs> queryLogsByFilter(@RequestBody Map<String, Object> params){
        System.out.println(params);
        return loginlogsService.queryLogsByFilter(params);
    }
}
